<template>
  <div>
    <el-table stripe
              v-loading="loading"
              element-loading-text="数据加载中"
              :data="list"
              style="width:100%"
              @sort-change="onSubmit"
              border>
      <el-table-column
        property="num"
        label="受试者号"
        width="120"
        sortable="custom"
        align="center">
      </el-table-column>
      <el-table-column
        label="名字"
        property="name"
        sortable="custom"
        align="center">
      </el-table-column>
      <el-table-column
        property="createDatetime"
        sortable="custom"
        label="通过筛选时间"
        align="center">
      </el-table-column>
      <el-table-column
        property="hospitalStatus"
        sortable="custom"
        inline-template
        label="住院状态"
        align="center">
           <span>
          {{row.hospitalStatus == 1?'入院':'出院'}}
           </span>
      </el-table-column>
      <el-table-column
        sortable="custom"
        label="进度"
        align="center"
        property="amount"
        inline-template
        width="300px">
        <template>
          <el-progress :stroke-width="10" :percentage="(row.amount/processAmount*100).toFixed(1)" :status="row.amount/processAmount==1?'success':''"></el-progress>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  // 在返回的数据列表中添加“percentage”字段，就可以实现动态显示进度条数据
  import http from '../../../api/http'
  export default {
    data () {
      return {
        loading: true,
        list:[],
        form: {
          filter: {sort: {num: 'asc'}},
          pageNo: 1,
          pageSize: 10
        },
        processAmount: 0
      }
    },
    methods: {
      onSubmit (sortCol) {
        var vm = this;
        if (sortCol && sortCol.prop != undefined && sortCol.prop != '' && sortCol.prop != 'undefined') {
          var sortJson = '{"' + sortCol.prop + '":"' + (sortCol.order == 'descending' ? 'desc' : 'asc') + '"}';
          vm.form.filter.sort = JSON.parse(sortJson);
          vm.form.pageNo = 1;
        }
        vm.loading = true;
        if (vm.$utils.getCurrenrProject().id == null) {
          vm.$notify({title: '操作提示', message: '请选择项目', type: 'error'});
        }
        http.postData(vm, "/pt/process/progress/" + this.$utils.getCurrenrProject().id, {
          json: JSON.stringify(vm.form.filter),
          pageNo: vm.form.pageNo,
          pageSize: vm.form.pageSize
        }, function (resp) {
          var ret = resp.body;
          if (ret.code == '111') {
            vm.list = ret.value[0];
            vm.processAmount=ret.value[1];
          }
          vm.loading = false;
        });
      },
      handleSizeChange () {
        this.form.pageNo = 1
        this.onSubmit()
      },
      handleCurrentChange (val) {
        this.form.pageNo = val
        this.onSubmit()
      }
    },
    created() {
      this.onSubmit();
    }
  }
</script>
<style>
</style>
